<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    var minimizedMaximum = function (n, quantities) {
      // 二分
      let l = 1
      let r = 100000
      while (l < r) {
        const middle = (l + r) >>> 1
        let storeCount = 0
        for (const quantitie of quantities) {
          storeCount += Math.ceil(quantitie / middle)
        }
        // 可以分配更多的商店，表示分配的数量可以再大点
        if (storeCount > n) {
          l = middle + 1
        } else {
          r = middle
        }
      }
      return l
    };
    console.log(minimizedMaximum(6, [11, 6]));
  </script>
</body>

</html>